<?php
class Translator {
	
	private static $instance = null;
	
	private $lang = array();
	
	private function __construct() {}
	
	public static function setup($lang) {
		self::instance()->lang = $lang;
	}
	
	public static function get($key) {
		if (!isset(self::instance()->lang[$key])) {
			throw new TranslatorException('Undefined key');
		}
		
		return self::instance()->lang[$key];
	}
	
	private static function instance() {
		if (self::$instance == null) {
			self::$instance = new Translator();
		}
		
		return self::$instance;
	}
}